/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dal;

import entity.*;
import entity.Enums.VendaStatus;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 *
 * @author Daniel
 */
public class DALVenda {

    public boolean insertVenda(Funcionario umFuncionario, VendaStatus status){
        boolean inseriu = false;
        try {
            String query = "INSERT INTO Venda ('funcionario') VALUES ("+umFuncionario.getId()+")";
            Statement statement = DALConnection.getStatement();
            if (statement.execute(query))
                inseriu = true;
        }catch(Exception ex){
            ex.printStackTrace();
        } finally{
            DALConnection.closeConnection();
        }

        return inseriu;
    }

    public int insertedVenda(Funcionario umFuncionario){
        int idVenda = 0;
        try {
            String query = "SELECT * FROM Venda WHERE Venda.Funcionario.idFuncionario = "+umFuncionario.getId()+" AND Venda.TipoStatus_idTipoStatus = "+1+")";
            Statement statement = DALConnection.getStatement();
            ResultSet resultSet = statement.executeQuery(query);
            if (resultSet.next())
                idVenda = resultSet.getInt(1);
        }catch(Exception ex){
            ex.printStackTrace();
        } finally{
            DALConnection.closeConnection();
        }

        return idVenda;

    }

    

}
